<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            border-collapse: collapse;
        }

        table th,td {
            padding: 10px;
            border: 1px solid aqua;
        }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>语文</th>
                <th>数学</th>
                <th>英语</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>刘畅</td>
                <td>78</td>
                <td>92</td>
                <td>93</td>
            </tr>
            <tr>
                <td>孙权</td>
                <td>71</td>
                <td>68</td>
                <td>57</td>
            </tr>
            <tr>
                <td>司马懿</td>
                <td>98</td>
                <td>67</td>
                <td>44</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td>合计</td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </tfoot>
    </table>
    <script>
        const tbody = document.querySelector("tbody");
        //col 需要计算的列位置，如第二列则为2
        function sum(col){
            let score = 0;
            for(let k = 0;k<tbody.children.length;k++){
                score += parseInt(tbody.children[k].children[col-1].innerText);
            }
            return score;
        }
        const table = document.querySelector("table");
        table.rows[4].cells[1].innerText = sum(2)
        table.rows[4].cells[2].innerText = sum(3)
        table.rows[4].cells[3].innerText = sum(4)
    </script>
</body>
</html>